package com.zjdiepu.www.manage.view;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.zjdiepu.www.base.BaseController;
import com.zjdiepu.www.base.enums.status.BusiStatus;
import com.zjdiepu.www.base.enums.status.LessInformationStatus;
import com.zjdiepu.www.base.enums.status.PhoneStatus;
import com.zjdiepu.www.base.enums.type.BusinessExtrasCodeType;
import com.zjdiepu.www.base.enums.type.DataDicType;
import com.zjdiepu.www.base.enums.type.ResultFlagType;
import com.zjdiepu.www.commpent.RedisObjectClient;
import com.zjdiepu.www.commpent.ViewScopeControllerHelper;
import com.zjdiepu.www.commpent.mapper.yw.YwBusinessVoMapper;
import com.zjdiepu.www.ibiz.cache.ICachedDictionaryService;
import com.zjdiepu.www.ibiz.system.IBaseCustomerService;
import com.zjdiepu.www.ibiz.yw.IYwBusinessService;
import com.zjdiepu.www.model.yw.dto.YwBusiness;
import com.zjdiepu.www.util.CachedEnums;
import com.zjdiepu.www.util.ExceptionHelper;

/**
 * 客户表Controller层<br/>
 * @author xiongxiaotun<br/>
 * @time 2017年05月11日 20时36分<br/>
 * @since 1.0<br/>
 */
@Controller
@RequestMapping(value= "BaseCustomerViewController", produces="text/html;charset=UTF-8")
@Api(tags = {"客户表"}, produces="text/html;charset=UTF-8")
public class BaseCustomerViewController extends BaseController {
    @Resource
    private IBaseCustomerService baseCustomerCarService;
    @Resource
    private RedisObjectClient redisObjectClient;
    @Resource
    private IYwBusinessService ywBusinessService;
    @Resource
    private YwBusinessVoMapper ywBusinessVoMapper;
    @Resource
    private ViewScopeControllerHelper viewScopeControllerHelper;
    @Resource
    private ICachedDictionaryService cachedDictionaryService;
    
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: baseCustomerDetail <br/>
     * @Description: 客户表详情 <br/>
     * @param model
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "客户表详情", response = Boolean.class, httpMethod="GET", tags={"客户表"})
    @RequestMapping(value = "customerDetail", method = RequestMethod.GET)
    public String customerDetail(Model model, String customerNo) {
    	if (StringUtils.isBlank(customerNo)) {
			ExceptionHelper.thow(ResultFlagType.PARAM_EMPTY);
		}
    	model.addAttribute("busiStatusNames", CachedEnums.getNames(BusiStatus.class));
    	model.addAttribute("phoneStatusNames", CachedEnums.getNames(PhoneStatus.class));
    	model.addAttribute("lessInformationStatusNames", CachedEnums.getNames(LessInformationStatus.class));
    	model.addAttribute("businessExtrasCodeTypeNames", CachedEnums.getNames(BusinessExtrasCodeType.class));
    	model.addAttribute("loanBank", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.LOAN_BANK, "请选择..."));
    	
    	List<YwBusiness> ywBusinesss = ywBusinessService.selectByCustomerNo(customerNo);
    	model.addAttribute("ywBusinesss", ywBusinesss);
    	
    	viewScopeControllerHelper.preparedAttachmentEnum(model);
    	viewScopeControllerHelper.preparedCarModel(model);
    	return "system/kehubiao/customerDetail";
    }
	
}
